<template>
	<div class="layout">
		<h3>{{msg}}</h3>

    <van-cell-group>
      <van-field
        v-model="username"
        label="用户名"
        icon="clear"
        placeholder="请输入用户名"
        required
        @click-icon="username = ''"
      />

      <van-field
        v-model="password"
        type="password"
        label="密码"
        placeholder="请输入密码"
        required
      />
    </van-cell-group><br>
    <br>
    <br>
    <van-button type="primary" size="large" @click="submit">登录</van-button>

	</div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'layout',
  data () {
    return {
      msg: '测试跨域',
      username: 'admin',
      password: 'admin'
    }
  },
  methods: {
    submit () {

      let fd = new FormData();

      let param = {
        manageAccount: this.username,
        managePassword: this.password
      };

      for (let o in param) {
        fd.append(o, param[o])
      }

      axios.post('http://47.100.4.239:8098/manage/toLogin',fd)
      .then((response) => {
        if (response.data.code == 200) {
          alert('登录成功！');
        } else {
          alert(response.data.msg);
        }
      })
      .catch((error) => {
        console.log(error);
      });
    }
  }
}
</script>

<style>
</style>